package com.zhm.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Date： 2021/3/15 22:24
 *
 * @author ZHM
 */
@RestController
@RefreshScope
public class ConfigClientController {

    /**
     * 从 配置中心 读取 配置信息
     */
    @Value("${spring.application.name}")
    private String name;

    @Value("${config.info}")
    private String configInfo;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping(value = "/get_name")
    public String getApplicationName() {
        return name;
    }

    @GetMapping(value = "/get_config_info")
    public String getConfigInfo() {
        return "当前端口号：" + serverPort + "  config 配置信息：" + configInfo;
    }

}
